#!/usr/bin/perl -w
#
# $Id: StringWindow.pm,v 1.22 2003/07/20 03:06:28 solovam Exp $
#
# This file is a part of gkismet
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#

#
# StringWindow class
#
package StringWindow;

use Gtk;
use Misc;
use ClistWindow;
use strict;

@StringWindow::ISA = qw(ClistWindow);

#
# Tell connection to start sending the info
#
sub activateConnection
{
	my $self = shift;
	if($self->{'gKismetApplication'}->countObservers('StringWindow') < 1)
	{
		$self->{'connection'}->enableStrings();
	}
}

#
# Tell connection to stop sending the info
#
sub deactivateConnection
{
	my $self = shift;
	if($self->{'gKismetApplication'}->countObservers('StringWindow') == 1)
        {
		$self->{'connection'}->disableStrings();
	}
}

#
# Is it a worthwhile update?
#
sub isInterstingUpdate
{
	my $self = shift;
	my $data = shift;

	if($data->{'changed'} eq 'string' && $self->{'connection'}->getString()->{'bssid'} eq $self->{'bssid'})
	{
		return $true;
	}
	else
	{
		return $false;
	}
}

#
# Window name (title)
#
sub getWindowName
{
	return 'String dump';
}

#
# Titles for CList columns
#
sub getColumnTitles
{
	return ('BSSID', 'Source MAC', 'Text');
}

#
# How many lines to show in window
#
sub getWindowDepth
{
	my $self = shift;
	return $self->{'gKismetApplication'}{'preferences'}->getPref('stringDepth');
}

#
# Get column data
#
sub getColumnData
{
	my $self = shift;
	my $string = $self->{'connection'}->getString();
	my $bssid = $string->{'bssid'};
	my $srcmac = $string->{'sourcemac'};
	my $text = $string->{'text'};
	return($bssid, $srcmac, $text);
}

1;
